/**********************************
 * 文件:rosapi接口 头文件-soap2cpp编译用
 * 创建者:华磊
 * 创建时间:2018.4.11
 * copyright:(c)同川科技
 * 备注:有未确定数据类型,暂时"待定"
 * 修改者:
 **********************************/
#ifndef ROSAPI_H
#define ROSAPI_H

#include <vector>

#include <string>

#import "import/stlvector.h"

struct UserInfo
{
    int account;                    //用户ID
    std::string password;           //密码
    std::string ip;                 //IP地址
    std::string operationSystem;    //操作系统
};

/**
 * @brief The Message struct        信息结构体
 */
struct Message
{
    int MessageLevel;               //消息级别
    long time;						//产生时间(2017.02.10修改)
    int robotId;                    //机器人id
    std::string componentClassName; //组件类名
    std::string messageType;        //消息类型
    int messageCode;                //消息ID
    int parameter1;                 //消息参数1
    int parameter2;                 //消息参数2
    int parameter3;					//消息参数3
    int parameter4;					//消息参数4
    std::string MessageInformation; //消息内容(提供用户可见)
};


/*---------------------------agv used(hmi->agvBaseControl->ros  ros->agvBaseControl)-----------------------------------------*/


enum E_MAP_SOLVER
{
    E_MAP_SOLVER_GMAPPING,
    E_MAP_SOLVER_CARTOGRAPHER,
    E_MAP_SOLVER_HECTOR
};

//enum E_LOCATION_SOLVER
//{
//    E_LOCATION_SOLVER_AMCL_LASER,
//    E_LOCATION_SOLVER_AMCL_ENCODER,
//    E_LOCATION_SOLVER_AMCL_IMU,
//    E_LOCATION_SOLVER_AMCL_LASER_IMU,
//    E_LOCATION_SOLVER_AMCL_LASER_IMU_ENCODER,
//    E_LOCATION_SOLVER_CARTOGRAPHER_LASER,
//    E_LOCATION_SOLVER_CARTOGRAPHER_LASER_IMU,

//};

enum E_LOCATION_SOLVER
{
    E_LOCATION_SOLVER_AMCL,
    E_LOCATION_SOLVER_CARTOGRAPHER_LASER,
    E_LOCATION_SOLVER_CARTOGRAPHER_LASER_IMU

};

enum E_ODOM_SOLVER
{
    E_ODOM_SOLVER_ENCODER,
    E_ODOM_SOLVER_LASER,
    E_ODOM_SOLVER_ENCODER_IMU,
    E_ODOM_SOLVER_LASER_ENCODER_IMU
};

enum E_TRAJECTORY_GLOBAL_SOLVER
{
    E_TRAJECTORY_GLOBAL_SOLVER_ASTAR,
    E_TRAJECTORY_GLOBAL_SOLVER_DIJKSTRAS,
};

enum E_TRAJECTORY_LOCAL_SOLVER
{
    E_TRAJECTORY_LOCAL_SOLVER_DWA,
    E_TRAJECTORY_LOCAL_SOLVER_BASELOCAL,
    E_TRAJECTORY_LOCAL_SOLVER_TEB
};

enum E_ROS_PACKAGE
{
    E_ROS_PACKAGE_MAIN,

};

enum E_ROS_PACKAGE_STATUS
{
    E_ROS_PACKAGE_STATUS_DOWN,
    E_ROS_PACKAGE_STATUS_NORMAL,
    E_ROS_PACKAGE_STATUS_ERROR
};

enum E_GOAL_STATUS
{
    E_GOAL_STATUS_PENDING,
    E_GOAL_STATUS_ACTIVE,
    E_GOAL_STATUS_PREEMPTED,
    E_GOAL_STATUS_SUCCEEDED,
    E_GOAL_STATUS_ABORTED,
    E_GOAL_STATUS_REJECTED,
    E_GOAL_STATUS_PREEMPTING,
    E_GOAL_STATUS_RECALLING,
    E_GOAL_STATUS_RECALLED,
    E_GOAL_STATUS_LOST,
    E_GOAL_STATUS_UNKNOWN
};

/**
 * @brief The vechileFeedbackVelocity struct
 *Get the velocity of the vechile according to the encoder counts, unit in m/s
 */


struct VehicleVelocity
{
    double x_move;//according to vehicle unit in m/s
    double y_move;
    double z_rotate;//unit is rad/s
};

struct VehiclePosition
{
    double x;//m
    double y;//m
    double rotate;//unit is rad
};

struct OdemeterData
{
    struct VehicleVelocity vel;
    struct VehiclePosition pos;
};

//***************AGV接口函数部分 hmi->agvBaseControl->ros********************************

//地图
int setMapSolver(struct UserInfo userInfo,enum E_MAP_SOLVER solverIn,
                 int laserCount,int &returnFlag);
int createMapStart(struct UserInfo userInfo,int &returnFlag);
int createMapEnd(struct UserInfo userInfo,std::string mapName,int &returnFlag);
int loadMap(struct UserInfo userInfo,std::string mapName,int &returnFlag);

//添加虚拟墙
int addVitrualBlock(struct UserInfo userInfo,std::string configFilePath,int &returnFlag);
int deleteVitrualBlock(struct UserInfo userInfo,int &returnFlag);
int addForbidenZone(struct UserInfo userInfo,double x_start,double y_start
                    ,double x_end,double y_end,int &returnFlag);

//定位
int setOdomSolver(struct UserInfo userInfo,enum E_ODOM_SOLVER solverIn,int &returnFlag);//选择odom enum 方法 int 返回标志
int setLocationSolver(struct UserInfo userInfo,enum E_MAP_SOLVER solverIn,int &returnFlag);
int getVehiclePosition(struct UserInfo userInfo,struct VehiclePosition& positionReturn);
int setVehiclePosition(struct UserInfo userInfo,struct VehiclePosition positionIn,int &returnFlag);

//轨迹规划和行驶
int setReplanCoutLimitWhenFailure(struct UserInfo userInfo,int countLimit,int &returnFlag);
int setTrajectoryGlobalPlanSolver(struct UserInfo userInfo,enum E_TRAJECTORY_GLOBAL_SOLVER solverIn,int &returnFlag);//选择全局规划器 enum 全局规划器 int 返回标志
int setTrajectoryLocalPlanSolver(struct UserInfo userInfo,enum E_TRAJECTORY_LOCAL_SOLVER solverIn,int &returnFlag);//选择局部规划器 enum 局部规划器 int 返回标志
int moveToPosition(struct UserInfo userInfo,struct VehiclePosition positionIn,
                   double velocity,int &returnFlag);
int moveFollowPath(struct UserInfo userInfo,std::vector<struct VehiclePosition> pathIn,
                   double velocity,int &returnFlag);
int changeVelocity(struct UserInfo userInfo,double velocity,int &returnFlag);
int getMovingStatus(struct UserInfo userInfo,enum E_GOAL_STATUS& status);
int getRemainningTime(struct UserInfo userInfo,double &timeOut);
int getRemainningDistance(struct UserInfo userInfo,double &distanceOut);
int ceaseMotion(struct UserInfo userInfo,int &returnFlag);
int startMotion(struct UserInfo userInfo,int &returnFlag);
int cancelMotion(struct UserInfo userInfo,int &returnFlag);

//设置
int setPositionArrivedAccuracy(struct UserInfo userInfo,double accuracyIn,int &returnFlag);
int setLocalPlanRange(struct UserInfo userInfo,double rangeIn,int &returnFlag);
int setVehicleBorderOffset(struct UserInfo userInfo,std::vector<double> point_x, std::vector<double> point_y,int &returnFlag);
int setGlobalBarrierOffset(struct UserInfo userInfo,double offsetIn,int &returnFlag);
int setLocalBarrierOffset(struct UserInfo userInfo,double offsetIn,int &returnFlag);
int resetRosAll(struct UserInfo userInfo,int &returnFlag);

//状态
int getRosPackageStatus(struct UserInfo userInfo,enum E_ROS_PACKAGE package,enum E_ROS_PACKAGE_STATUS &status);

//IMU校准
int startImuCalibrate(struct UserInfo userInfo,int &returnFlag);
int stopImuCalibrate(struct UserInfo userInfo,int &returnFlag);

//信息传递
int getMessage(struct UserInfo userInfo,std::vector<struct Message> &messageListReturn);

int setWheelOdometerData(struct UserInfo userInfo,int robotIdIn,struct OdemeterData odemeterDataReturn,int &returnFlag);

int getVehicleVelocityComand(struct UserInfo userInfo,int robotIdIn,struct  VehicleVelocity &velocityComamnd);

int setWheelMoveSpeed(struct UserInfo userInfo,int robotIdIn, std::vector<double>wheelMoveSpeed,int &returnFlag);

int setWheelPathLength(struct UserInfo userInfo,int robotIdIn, std::vector<double>wheelPathLength,int &returnFlag);


#endif // ROSAPI_H
